package com.markus.code.exam.同花顺;

import java.util.Scanner;

/**
 * Author:markusZhang
 * Date:Create in 2020/9/20 17:13
 * todo:
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){
            String str = scanner.next();
            System.out.println(stringCompress(str));
        }
    }
    private static String stringCompress(String str){
        char[] arr = str.toCharArray();
        //新建一个直接累加的数组
        StringBuilder arr1 = new StringBuilder();
        int count = 1;
        //放入第一个字符
        arr1.append(arr[0]);
        //将目标字符数组的第一个元素作为比较目标存入temp
        char temp = arr[0];
        for (int j=1;j<arr.length;j++){
            //遍历字符数组
            if (temp == arr[j]){
                //判断数组arr当前对象与比较目标temp是否相等
                count ++;
            }else{
                arr1.append((char)(count+'0'));
                arr1.append(arr[j]);
                temp = arr[j];
                count = 1;
            }
        }
        //当最后一位与前一位相等时会直接跳出循环
        arr1.append((char)(count+'0'));
        return arr1.toString();
    }
}
